package info.wegosoft.android.activity;

import info.wegosoft.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

/**
 * 
 * Filename:    LoginActivity.java 
 * Package:     info.wegosoft.activity 
 * Description: TODO(这里用一句话描述这个类的作用)
 * Copyright:   Copyright (c) wegosoft.info 2011  
 * @author:     李辉 
 * email:       fzlihui@gmail.com
 * @version:    1.0  
 * Create at:   2011-5-10 下午04:06:04
 */
public class LoginActivity extends Activity {
	//初始化时载入数据的
	private ProgressDialog loginProgressDialog;
	private Button login;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        this.initButton();
    }
    
    private void initButton()
    {
    	//登录按钮,这里登录后直接跳转到主菜单界面,登录验证就不做了
    	this.login = (Button) findViewById(R.id.loginBtn);
    	login.setOnClickListener(new Button.OnClickListener(){		
			public void onClick(View v) {
				//显示Progress对话框
				loginProgressDialog = ProgressDialog.show(LoginActivity.this,null,"登陆中",true);
				new Thread()
			    { 
			        public void run()
			        { 
			        	try {
							Thread.sleep(1000);
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
						Intent intent = new Intent();
						intent.setClass(LoginActivity.this, MBlogPlatformListActivity.class);
						LoginActivity.this.finish();
						startActivity(intent);
			            // 卸载所创建的myDialog对象。
			        	loginProgressDialog.dismiss();    
			        }
			    }.start(); //开始运行运行线程 				
			}  		
    	});	
    }
    
    @Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {

		if (keyCode == KeyEvent.KEYCODE_BACK) {

			new AlertDialog.Builder(LoginActivity.this)
					.setTitle("真的要离开？")
					.setMessage("确定要离开?")
					.setPositiveButton("确定",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int which) {
									LoginActivity.this.finish();
								}
							}).setNegativeButton("取消", null).show();

		}

		return super.onKeyDown(keyCode, event);
	}
}